﻿<Window x:Class="EtlViewer.Viewer.LogViewer"
        x:ClassModifier="internal"
        xmlns:local="clr-namespace:EtlViewer.Viewer"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:utils="clr-namespace:EtlViewer.Viewer.UIUtils"
        Title="Diagnostics" Height="300" Width="1024" Closing="Window_Closing"
        xml:space="preserve" 
        WindowStartupLocation="CenterOwner"
        Icon="CSD_banner.ico" 
        Style="{StaticResource MetroWindow}" Name="LogWindow">
    <Window.Resources>
        <utils:CustomBoolToVisibilityConverter x:Key="BooleanToVisibilityConverter" />
        <Style x:Key="ReadonlyTextbox" TargetType="{x:Type TextBox}" BasedOn="{StaticResource DefaultTextBoxStyle}">
            <Setter Property="BorderThickness" Value="0" />
            <Setter Property="Foreground" Value="{StaticResource MetroBlueColorBrush}" />
            <Setter Property="BorderBrush" Value="White"></Setter>
            <Setter Property="Margin" Value="10,0,50,0"></Setter>
        </Style>
    </Window.Resources>
    <Window.InputBindings>
    <KeyBinding Key="Escape" Command="{x:Static local:LogViewer.CloseCommand}" 
                CommandParameter="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType=Window}}" />
</Window.InputBindings>
    <Grid Margin="5,5,5,0">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>
            <Grid Grid.Row="0">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="*"></ColumnDefinition>
                    <ColumnDefinition Width="Auto"></ColumnDefinition>
                </Grid.ColumnDefinitions>
                <WrapPanel Orientation="Horizontal"  Margin="5" Grid.Column="0">
                    <StackPanel Orientation="Horizontal">
                        <TextBlock  Style="{StaticResource ControlLabelStyle}">VERSION</TextBlock>
                        <TextBox Name="txtVersion" IsReadOnly="True" Style="{StaticResource ReadonlyTextbox}"></TextBox>
                    </StackPanel>
                    <StackPanel Orientation="Horizontal" >
                        <TextBlock  
                                   HorizontalAlignment="Stretch" 
                                   Style="{StaticResource ControlLabelStyle}">APPROOT</TextBlock>
                        <TextBox Name="txtAppRoot" IsReadOnly="True" Style="{StaticResource ReadonlyTextbox}"></TextBox>
                    </StackPanel>
                    <StackPanel Orientation="Horizontal">
                        <TextBlock Style="{StaticResource ControlLabelStyle}">ASSEMBLY CACHE</TextBlock>
                        <TextBox Name="txtAssemblyCache" IsReadOnly="True" Style="{StaticResource ReadonlyTextbox}"></TextBox>
                    </StackPanel>
                </WrapPanel>
            <TextBlock Grid.Column="1" HorizontalAlignment="Right" Margin="5">
                     <Hyperlink NavigateUri="mailto:sajaya@microsoft.com?Subject=SvcPerf Feedback"  RequestNavigate="Hyperlink_RequestNavigate_1">CONTACT</Hyperlink>
                    </TextBlock>
            </Grid>
        <ListBox  Grid.Row="1" 
                  Name="logList" 
                  HorizontalAlignment="Stretch" 
                  VerticalAlignment="Stretch"  
                  BorderThickness="0" 
                  Margin="5"
                  ScrollViewer.CanContentScroll="False" >
            <ListBox.ItemContainerStyle>
                <Style TargetType="ListBoxItem">
                    <Setter Property="HorizontalContentAlignment" Value="Stretch"></Setter>
                </Style>
            </ListBox.ItemContainerStyle>
            <ListBox.ItemTemplate>
                <DataTemplate>
                    <Grid HorizontalAlignment="Stretch">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto"/>
                            <ColumnDefinition Width="5" />
                            <ColumnDefinition Width="Auto" />
                            <ColumnDefinition Width="*" />                            
                        </Grid.ColumnDefinitions>
                        <Button HorizontalAlignment="Left" VerticalAlignment="Top" VerticalContentAlignment="Top" Grid.Column="0"                                 
                                Content="📧"
                                FontSize="15"
                                FontWeight="ExtraLight"
                                Command="{Binding Path=DataContext.SendFeedbackCommand, ElementName=LogWindow }"
                                CommandParameter="{Binding}">
                            <Button.Style>
                                <Style TargetType="{x:Type Button}" BasedOn="{StaticResource DefaultHyperlinkButtonStyle}">
                                    <Setter Property="Visibility" Value="Hidden" />
                                    <Setter Property="Height" Value="20"></Setter>
                                    <Style.Triggers>
                                        <DataTrigger Binding="{Binding RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type ListBoxItem}},Path=IsMouseOver}" Value="True">
                                            <Setter Property="Visibility" Value="Visible" />
                                        </DataTrigger>
                                    </Style.Triggers>
                                </Style>
                            </Button.Style>                           
                        </Button>
                        <TextBlock Grid.Column="1" Visibility="{Binding Path=IsError, Converter={StaticResource BooleanToVisibilityConverter}}" 
                                   Foreground="Red" FontWeight="Bold">!</TextBlock>
                        <Border Grid.Column="2" BorderThickness="0,0,1,0" BorderBrush="LightGray" Margin="0,0,5,0"> 
                        <TextBlock Text="{Binding Path=DateTime}" Padding="5,0,5,0"></TextBlock>
                        </Border>
                        <TextBlock Text="{Binding Path=LogMessage}" Grid.Column="3" ></TextBlock>                        
                    </Grid>
                </DataTemplate>
            </ListBox.ItemTemplate>
        </ListBox>      
    </Grid>
</Window>
